package com.test.demo01_triangle;

import androidx.appcompat.app.AppCompatActivity;

import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.widget.Toast;

import com.test.demo01_triangle.databinding.ActivityMainBinding;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

public class MainActivity extends AppCompatActivity {

    private final String TAG = "MainActivity";

    private ActivityMainBinding binding;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!OpenGLUtil.isSupportEs2(this)) {
            showToast(TAG, "不支持OpenGL 2.0");
            finish();
        }
        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        binding.glSurfaceView.setEGLContextClientVersion(2);

//        binding.glSurfaceView.setRenderer(new Renderer01(this));
        binding.glSurfaceView.setRenderer(new Renderer02(this));
    }

    private void showToast(String tag, String msg) {
        LogUtil.d(tag, "showToast() -- msg: " + msg);
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
    }
}